﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Asteroids.Graphics;
using Microsoft.Xna.Framework;

namespace Asteroids.Entities.Components
{
    public class ProjectileEntityTemplate : EntityTemplate
    {
        private VertexPositionColor2D[] _bulletModel
            = new VertexPositionColor2D[]
                {
                    new VertexPositionColor2D() { Position = new Vector2(0, 2), Color = Color.Red },
                    new VertexPositionColor2D() { Position = new Vector2(1, -1), Color = Color.Orange },
                    
                    new VertexPositionColor2D() { Position = new Vector2(1, -1), Color = Color.Orange },
                    new VertexPositionColor2D() { Position = new Vector2(-1, -1), Color = Color.Green },
                    
                    new VertexPositionColor2D() { Position = new Vector2(-1, -1), Color = Color.Green},
                    new VertexPositionColor2D() { Position = new Vector2(0, 2), Color = Color.Red }
                };


        public override void PopulateEntity(Entity e)
        {
            TransformComponent transform = new TransformComponent();
            PhysicsComponent physics = new PhysicsComponent();
            VertexPrimitiveRenderComponent rendering = new VertexPrimitiveRenderComponent();

            e.AddComponent<TransformComponent>(transform);
            e.AddComponent<VertexPrimitiveRenderComponent>(rendering);
            e.AddComponent<PhysicsComponent>(physics);

            physics.RotationalVelocity = 4;
            physics.RotationalAcceleration = 90;
            rendering.Scale = 4;
            rendering.Model = _bulletModel;
        }
    }
}
